def countdown(n):
    while n > 0:
        yield n
        n -= 1

# 创建生成器对象
generator = countdown(10)

# 通过迭代生成器获取值
print(next(generator))
print(next(generator))
print(next(generator))

# 使用 for 循环迭代生成器
for value in generator:
    print(value)